﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using SysMisc;

namespace Kernel
{
    /// <summary>
    /// 系统配置类
    /// </summary>
    public class SystemConfig
    {
        public SystemConfig()
        {
            CatgPapers = new List<xmlCatgPaper>();
            DrawPapers = new List<xmlDrawPaper>();
        }
        [XmlArray("CatgPapers")]
        public List<xmlCatgPaper> CatgPapers { get; set; } //目录页
        [XmlArray("Files")]
        public List<xmlDrawPaper> DrawPapers { get; set; }    //图纸页

        public static SystemConfig LoadSystemConfigFile()
        {
            return SysMisc.Serialization.DeSerializeFromXml<SystemConfig>("AppConfig.xml");
        }
    }

    [XmlType(TypeName = "xmlCatgItem")]
    public class xmlCatgItem
    {
        [XmlAttribute]
        public double Offset_X { get; set; }   //横向偏移
        [XmlAttribute]
        public double Offset_Y { get; set; }   //纵向偏移
        [XmlAttribute]
        public string Key { get; set; }   //条目的关键字
    }

    [XmlType(TypeName = "xmlCatgPaper")]
    public class xmlCatgPaper/*表示一整个图纸目录*/
    {
        public xmlCatgPaper()
        {
            CatgPages = new List<xmlCatgPage>();
        }

        [XmlAttribute]
        public string PaperSpec { get; set; }/*图纸规格（图框的名称），应该根据*/
        [XmlAttribute]
        public int MaxItemCount { get; set; }   //图纸支持的总最大条目数
        [XmlArray("CatgPages")]
        public List<xmlCatgPage> CatgPages { get; set; } //目录页列表
        [XmlArray("CatgPageItems")]
        public List<xmlCatgItem> CatgPageItems { get; set; } //目录页列表
    }

    [XmlType(TypeName = "xmlCatgPage")]
    public class xmlCatgPage/*表示图纸目录中的一页*/
    {
        /*序号*/
        [XmlAttribute]
        public double Offset_X1 { get; set; }   //横向偏移
        [XmlAttribute]
        public double Offset_Y1 { get; set; }   //纵向偏移
        /*图纸编号*/
        [XmlAttribute]
        public double Offset_X2 { get; set; }   //横向偏移
        [XmlAttribute]
        public double Offset_Y2 { get; set; }   //纵向偏移
        /*图纸名称*/
        [XmlAttribute]
        public double Offset_X3 { get; set; }   //横向偏移
        [XmlAttribute]
        /*图纸张数*/
        public double Offset_Y3 { get; set; }   //纵向偏移
        [XmlAttribute]
        public double Offset_X4 { get; set; }   //横向偏移
        [XmlAttribute]
        public double Offset_Y4 { get; set; }   //纵向偏移

        [XmlAttribute]
        public double Step_X { get; set; }   //填充条目时，X方向上的步进
        [XmlAttribute]
        public double Step_Y { get; set; }   //填充条目时，Y方向上的步进
        [XmlAttribute]
        public int MaxItemCount { get; set; }   //当前图纸页支持的最大条目数
    }

    public class xmlDrawPaper
    {
        public xmlDrawPaper()
        {
            CatgItems = new List<xmlCatgItem>();
        }

        [XmlAttribute]
        public string PaperSpec { get; set; }/*图纸规格（图框的名称），应该根据*/
        [XmlArray("CatgItems")]
        public List<xmlCatgItem> CatgItems { get; set; } //图纸属性列表
    }
}
